/*
 * JavaScript file
 */
function init()
{
    resetText();

    // Configuration Options here

    // StartSession here
	// BangoAgent.onStartSession([You Application ID]);
};

function exitApplication()
{
	BangoAgent.onEndSession();
	window.close();
};

function log()
{
    BangoAgent.onEvent(getTxtEventName(), getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("onEvent");
};

function error()
{
	BangoAgent.onError("TestError", "This is my test error", "Method Name");
	setMessage("onError");
};

function pageView()
{
	BangoAgent.onPageView(getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("onPageView");
};

function search()
{
	BangoAgent.onSearch(getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("search");
};

function liveVideoStart()
{
	BangoAgent.onLiveVideoStart(getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("onLiveVideoStart");
};

function liveVideoStop()
{
	BangoAgent.onLiveVideoStop(getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("onLiveVideoStop");
};

function onDemandVideoStart()
{
	BangoAgent.onDemandVideoStart(getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("onDemandVideoStart");
};

function onDemandVideoStop()
{
	BangoAgent.onDemandVideoStop(getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("onDemandVideoStop");
};

function idle()
{
	BangoAgent.onIdle(getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("onIdle");
};

function resume()
{
	BangoAgent.onResume(getTxtEventValue(), getTxtEventDetail(), getEventParameters());
	setMessage("onResume");
};

function postNow()
{
	BangoAgent.postEvents();
	setMessage("postEvents");
};

function viewBatch()
{
    alert(BangoAgent.viewBatch());
};

function writelog(text)
{
	document.getElementById("lblMessage").innerHTML += text +"<br/>";
};

function getEventParameters()
{
    var eventParameters = null;

    if (getTxtParamName1().length > 0 || getTxtParamName2().length > 0)
    {
        eventParameters = new Array();
        if (getTxtParamName1().length > 0)
        {
            eventParameters.push(new BangoEventParameter(getTxtParamName1(), getTxtParamValue1()));
        }

        if (getTxtParamName2().length > 0)
        {
            eventParameters.push(new BangoEventParameter(getTxtParamName2(), getTxtParamValue2()));
        }
    }
    return eventParameters;
};

function resetText()
{
    setTxtEventName("WRT Event");
    setTxtEventDetail("WRT Event Detail");
    setTxtEventValue("WRT Event Value");
    setTxtParamName1("BGO_SOURCE");
    setTxtParamValue1("WRT SOURCE");
    setTxtParamName2("BGO_TERM");
    setTxtParamValue2("WRT TERM");
	setMessage("");
};

function clearText()
{
    setTxtEventName("");
    setTxtEventDetail("");
	setTxtEventValue("");
	setTxtParamName1("");
	setTxtParamValue1("");
    setTxtParamName2("");
    setTxtParamValue2("");
};

function setMessage(message)
{
	document.getElementById("lblMessage").innerText = message;
	setTime();
};

function setTime()
{
	document.getElementById("lblTime").innerText = Date();
};

function getTxtEventName()
{
	return document.getElementById("txtEventName").value;
};

function setTxtEventName(value)
{
	document.getElementById("txtEventName").value = value;
};

function getTxtEventDetail()
{
	return document.getElementById("txtEventDetail").value;
};

function setTxtEventDetail(value)
{
	document.getElementById("txtEventDetail").value = value;
};

function getTxtEventValue()
{
	return document.getElementById("txtEventValue").value;
};

function setTxtEventValue(value)
{
	document.getElementById("txtEventValue").value = value;
};

function getTxtParamName1()
{
	return document.getElementById("txtParamName1").value;
};

function setTxtParamName1(value)
{
	document.getElementById("txtParamName1").value = value;
};

function getTxtParamValue1()
{
	return document.getElementById("txtParamValue1").value;
};

function setTxtParamValue1(value)
{
	document.getElementById("txtParamValue1").value = value;
};

function getTxtParamName2()
{
	return document.getElementById("txtParamName2").value;
};

function setTxtParamName2(value)
{
	document.getElementById("txtParamName2").value = value;
};

function getTxtParamValue2()
{
	return document.getElementById("txtParamValue2").value;
};

function setTxtParamValue2(value)
{
	document.getElementById("txtParamValue2").value = value;
};